package com.qf.search.mq;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.cloud.stream.annotation.StreamListener;

import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class StreamReceive {

    @StreamListener("stream")
    public void receive(String msg,
                        @Header(name = AmqpHeaders.CHANNEL) Channel channel,
                        @Header(name = AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws IOException {
        System.out.println("接收到消息：" + msg);
        channel.basicAck(deliveryTag,false);
    }
}
